/**
 * 
 */
package com.ac4j.algorithm;

import com.ac4j.match.Position;
import com.ac4j.sample.SampleImage;

/**
 * @author Administrator
 * 
 */
public class AllLocating extends AbstractLocatingAlgorithm {
	int pointX = 0;
	int pointY = -1;

	/**
	 * @param sourceimg
	 */
	public AllLocating(SampleImage sourceimg) {
		super(sourceimg);

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.ac4j.algorithm.AbstractLocatingAlgorithm#Feedback(float)
	 */
	@Override
	public void Feedback(float position_matchscore) {
		// do nothing for this implement

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.ac4j.algorithm.AbstractLocatingAlgorithm#NextPosition()
	 */
	@Override
	public Position NextPosition() {
		pointY++;
		if (pointY < sourceimg.getWidth()) {
			return new Position(pointX, pointY);
		} else {
			pointY = 0;
			pointX++;
			if (pointX < sourceimg.getHeight()) {
				return new Position(pointX, pointY);
			} else {
				return null;
			}
		}
	}

	@Override
	public boolean HasNext() {
		if (pointY + 1 >= sourceimg.getWidth()
				&& pointX + 1 >= sourceimg.getHeight())
			return false;
		return true;
	}

}
